package day0910.demo4;

/**
 * @Author:galaxy_yan
 * @Date: 2022/9/10
 * @Time: 20:55
 * @Description
 */
public class Computer {

    public void powerOn(){
        System.out.println("打开笔记本电脑电源");
    }

    public void powerOff(){
        System.out.println("关闭笔记本电脑电源");
    }

    public void useDevice(IUSB usb){
        usb.openDevice();
        if(usb instanceof Mouse){
            Mouse mouse=(Mouse) usb;
            mouse.click();
        }else if(usb instanceof KeyBoard){
            KeyBoard keyBoard=(KeyBoard) usb;
            keyBoard.input();
        }
        usb.closeDevice();
    }
}
